package com.tanhua.controller;

import com.tanhua.service.SmallVideoService;
import com.tanhua.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/smallVideos")
public class SmallVideoController {

    @Autowired
    private SmallVideoService smallVideoService;

    @PostMapping
    public ResponseEntity publishVideo(MultipartFile videoThumbnail,MultipartFile videoFile) throws Exception{
        smallVideoService.publishVideo(videoThumbnail,videoFile);
        return ResponseEntity.ok(null);
    }

    @GetMapping
    public ResponseEntity videoList(@RequestParam(defaultValue = "1") Integer page,
                                    @RequestParam(defaultValue = "10") Integer pagesize){
        PageResult pr = smallVideoService.videoList(page,pagesize);
        return ResponseEntity.ok(pr);
    }


}
